﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace GetHistoryData
{
    public class StockListXXX
    {
        #region Members.

        public static readonly StockListXXX Instance = new StockListXXX();

        #endregion

        #region Ctor.

        protected StockListXXX()
        {
        }

        #endregion

        #region Properties

        public string AllStockPath
        {
            get
            {
                return System.Windows.Forms.Application.StartupPath + System.Configuration.ConfigurationManager.AppSettings["DailyOldPath"];
            }
        }

        private List<StockListItem> allStock = null;
        public List<StockListItem> AllStock
        {
            get
            {
                if (allStock == null)
                {
                    allStock = new List<StockListItem>();

                    Directory
                        .GetFiles(AllStockPath)
                        .ToList()
                        .ForEach(t => allStock
                            .Add(new StockListItem()
                            {
                                StockCode = new FileInfo(t).Name.Substring(0, 6)
                            }));
                }
                return allStock;
            }
        }

        #endregion
    }
}
